package com.dailyblue.java.boot.security.project.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dailyblue.java.boot.security.project.bean.Powers;
import org.apache.ibatis.annotations.*;

import java.util.Set;

@Mapper
public interface PowersMapper extends BaseMapper<Powers> {
    @Select("select * from powers where id in (select pid from user_power where uid=#{userId})")
    Set<Powers> findAllPowerByUserId(int userId);

    @Select("select * from powers where id in(select pid from role_power where rid=#{roleId})")
    Set<Powers> findAllPowerByRoleId(int roleId);
    @Delete("delete from user_power where uid=#{uid}")
    void deletePowerByUserId(int uid);
    @Insert("insert into user_power values(null,#{uid},#{pid})")
    void savePower(@Param("uid") int uid,@Param("pid") int pid);
}
